<template>
  <div class="selectPrice">
    <el-table
      ref="multipleTable"
      :data="service"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection"> </el-table-column>
      <el-table-column prop="name" label="项目名称">
        <template slot-scope="scope">{{ scope.row.name }}</template>
      </el-table-column>
    </el-table>
    <div class="buts">
          <el-button  type="success" @click="batchPrint">批量打印</el-button>
    </div>
  </div>
</template>
<script>
export default {
  props: ["data",'order_type'],
  data() {
    return {
      service: [],
      checkoutData:[],//选中的数据
    };
  },
  mounted() {
    
    this.service = this.data.service;
  },
  methods: {
    handleSelectionChange(e) {
    
      this.checkoutData=e;
    },
    batchPrint(){
            console.log("this",this.checkoutData)

                if(this.checkoutData.length==0){
                        return  this.$message({
                                    message: '请选择你要打印的选项',
                                    type: 'warning'
                                    });
                }

             this.chufangdata = {
                 ...this.data,
                 service:this.checkoutData,
             };
          
             console.log(" this.chufangdata", this.chufangdata)
               const { href } = this.$router.resolve({
              path: "/bai/chufangZL",
              query: { cfdata: JSON.stringify(this.chufangdata) },
            });
            window.open(href, "_blank");
        //  this.chufangdata.drug=[];
        //   if (
        //     this.order_type != 3 &&
        //     this.order_type != 1 &&
        //     this.order_type != 4
        //   ) {
          
        //     this.chufangdata.service.forEach((res) => {
             
        //       this.chufangdata.drug.push({
        //         drug: {
        //           name:res.service.name,
        //           specification: "",
        //           dose_base: "",

        //           base_unit:res.once + "次",

        //           price: res.amount,

        //           usage: res.service.remark,
        //           each_dos: "",
        //           fee_category: "",
        //         },
        //       });
        //     });
            
        //   } else {
        //     this.chufangdata.drug.forEach((item) => {
        //       item.drug.each_dos = item.each_dos
        //         ? this.thatF.pinci.find((res) => res.id == item.each_dos)[
        //             "name"
        //           ]
        //         : "";
        //       item.drug.usage = item.usage
        //         ? this.thatF.geiyao.find((res) => res.id == item.usage)["name"]
        //         : "";
        //     });
        //   }
      

        //   var cfdata = JSON.stringify(this.chufangdata);
        //   if (this.order_type == 3) {
        //     const { href } = this.$router.resolve({
        //       path: "/bai/chufangje",
        //       query: { cfdata: cfdata },
        //     });
        //     window.open(href, "_blank");
        //   } else {
        //     const { href } = this.$router.resolve({
        //       path: "/bai/chufangZL",
        //       query: { cfdata: cfdata },
        //     });
        //     window.open(href, "_blank");
        //   }
    },
  },
};
</script>
<style lang="scss" scoped>
    .buts{
        margin-top: 20px;
        text-align: right;
       
    }
  .selectPrice{
    /deep/  .el-table .el-table__cell{
        padding: 0.75rem 0 !important; 
    }
  }  
</style>